<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: show_tip_results.tpl.php 1151 2008-06-24 15:07:32Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>
<div id="joomleague">
<!-- Header with Project Name-->
<?php if ($showTipResults_config['show_project_heading'] == "1" OR $overall_config['show_project_heading'] == "1") { ?>
<div class="componentheading" <?php if ($showTipResults_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
<!-- Druckfunktion -->
<?php if ($showTipResults_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") {
$htmlHelper->PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->
<?php } ?>
<!-- Header END -->

<!-- Bereichs�berschrift z.B Tabelle, Tippabgabe usw. -->
<table width="100%" class="contentpaneopen">
  <tr>
    <td class="contentheading"><?php echo _JL_PAGE_TITLE_TIP_OVERVIEW;?> <?php printf("%s. %s&nbsp;", $current_round, _JL_MATCHDAY);?></td>
    <?php if ($showTipResults_config['show_matchday_dropdown'] == "1") { ;?>
    <td align="right" nowrap="nowrap"><?php echo _JL_MATCHDAYS_SELECT;?><?php echo $pageNav2 ?></td>
    <?php } ;?>
  </tr>
</table>
<br />
<!-- Bereichs�berschrift Ende -->

<!-- Main START -->
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
<tr class="sectiontableheader" align="center"><td><?php echo _USERNAME;?></td>
<?php
    $thistime=$joomleague->getTimestamp('',1);
    $k = 0;
    $round_date = "";
   
    foreach($matches as $v){
      $match = new Match ($database);
    	$match->load($v->match_id);
    	$hometeam = new JL_Team($database);
			$hometeam->load($match->matchpart1);
			$guestteam = new JL_Team($database);
			$guestteam->load($match->matchpart2);
      $mrl = "";

      if ($match->matchpart1_result == "") { 
        $match->matchpart1_result = "-";
       }
       if ($match->matchpart2_result == "") { 
        $match->matchpart2_result = "-";
       }

?>
          <td align="center"><?php echo $hometeam->short_name;?><br /><?php echo $match->matchpart1_result.":".$match->matchpart2_result;?><br /><?php echo $guestteam->short_name;?></td>


<?php
      

    }
?>
        <?php if ($showTipResults_config['show_average_points'] == "1") echo '<td>&#216;</td>';?>
        <?php if ($showTipResults_config['show_points'] == "1") echo '<td>'._JL_TIP_RANKING_POINTS.'</td>';?>
        </tr>
<?php
$spaltenzahl=count($matches)+3;

if (!empty($username))
{
  foreach ($username AS  $key=>$val)
  {
    $class = ($k == 0)? 'sectiontableentry1' : 'sectiontableentry2';
    $tdclass = '';
    $bold = '';
    if (   $key  ==   $my->id   ) {
    	$tdclass = 'highlight';
		$bold = 'font-weight:bold;';} 
    
    echo '<tr class="'.$class.'" align="center"><td class="'.$tdclass.'" style="'.$bold.'">';
    if ($showTipResults_config['link_name_to'] == "1")
    echo '<a href="'.sefRelToAbs(JL_COMPONENT_LINK.'&amp;func=showUser&amp;p='.$joomleague->id.'&amp;uid='.$key.JL_ITEMID_SUFFIX).'">'.$username[$key].'</a>';
    else echo $username[$key];
    echo '</td>';
    foreach($matches as $v)
    {
    	$match = new Match ($database);
    	$match->load($v->match_id);
      $i=0;
	  $vdatum = $joomleague->getTimestamp($match->match_date);
      foreach($rows AS $row)
      {
      // <td></td> aus der ausgabe des spielers herausgezogen und ausgabetext bei joker hinzugef�gt 2007/05/05
        if($row->match_id==$match->match_id&&$row->user_id==$key)
        {
          echo '<td class="'.$tdclass.'" style="'.$bold.'">';

          if ($joomleague->mode==0) {
                        if(isset($joker[$key]) && $joker[$key]==$row->match_id && $joomleague->tip_joker == 1) $jokermark = "*";
              else $jokermark = "";
              if (($thistime>=$vdatum) || ($my->id==$key)) echo $row->tip_home.":".$row->tip_away."<sub style='color:red;'>".$points[$row->user_id][$row->match_id].$jokermark."</sub>";
              else  echo "     -:-";
                    } else {
              if (($thistime>=$vdatum) || ($my->id==$key)) echo $row->tip."<sub style='color:red;'>".$points[$row->user_id][$row->match_id]."</sub>";
              else  echo "     -";
                    }
          echo "</td>\n";
          $i++;
        }
           
      }
    
      if ($i==0) {
                if (($thistime>=$vdatum) || ($my->id==$key)) {
                    echo '<td class="'.$tdclass.'" style="'.$bold.'">n/a</td>'."\n";
                } else {
                    if ($joomleague->mode==0)  echo '<td class="'.$tdclass.'" style="'.$bold.'">-:-</td>'."\n"; else echo '<td class="'.$tdclass.'" style="'.$bold.'">-</td>'."\n";
                }
            }
      
    }
    if ($totaltips[$key]>0) $averagepoints=number_format(round($totalpoints[$key]/$totaltips[$key],2),2); else $averagepoints=number_format(0,2);
  if ($showTipResults_config['show_average_points'] == "1") echo '<td class="'.$tdclass.'" style="'.$bold.'">'.$averagepoints.'</td>';
  if ($showTipResults_config['show_points'] == "1") echo '<td class="'.$tdclass.'" style="'.$bold.'"><b>'.$totalpoints[$key].'</b></td>';
  echo "</tr>\n";
  $k = 1 - $k;
  }
}
else echo "<tr><td colspan=\"$spaltenzahl\" align=\"center\">"._JL_TIP_RESULTS_NO_TIP1."</td></tr>"
?>
</table>
<!-- Main END -->
<div style="text-align:center">
<?php
$url=JL_COMPONENT_LINK.'&amp;func=showTipResults&amp;p='.$joomleague->id.'&amp;r='.($round);
if($page>0) echo '<a href="'.sefRelToAbs($url.'&amp;page='.($page-1).JL_ITEMID_SUFFIX).'">'._PN_PREVIOUS.'</a>&nbsp;&nbsp;';
//echo _PN_PAGE.':';
if ($anzahluser>$limit) 
for ($x=0;$x<intval((($anzahluser+$limit)/$limit));$x++) {
	$pagenumber=$x+1;
	if ($x!=$page) echo '<a href="'.sefRelToAbs($url.'&amp;page='.($x).'&amp;Itemid='.$Itemid).'">'.$pagenumber.'</a>&nbsp;';
	else echo '<b>'.$pagenumber.'</b>&nbsp;';
}
if($page < intval($anzahluser / $limit)) echo '&nbsp;&nbsp;<a href="'.sefRelToAbs($url.'&amp;page='.($page+1).'&amp;Itemid='.$Itemid).'">'._PN_NEXT.'</a>';
?>
</div>

<?php if ($showTipResults_config['show_matchday_pagenav'] == "1") { ;?>
<!-- Matchdays Output  -->
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr>
   <td align="center">
   <br />
   <?php echo $pageNav ?></td>
  </tr>
</table>
<!-- Matchdays Output END -->
<?php } ;?>

<?php if ($showTipResults_config['show_help'] == "1") { ;?>
<br />
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td valign="top"><b><?php echo _JL_HINT;?></b></td>
    <td><?php echo _JL_TIP_RESULTS_HINT1;?><br /><?php echo _JL_TIP_RESULTS_HINT2;?></td>
  </tr>
</table>
<?php } ;?>

<!-- Print Button START -->
<?php if ($showTipResults_config['show_back_button'] > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($showTipResults_config['show_back_button'] == "1" OR $overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
  echo "</div>";
};?>
<!-- Print Button END -->
</div>
